#include "pcmaacdecodethread.h"

PCMAACDecodeThread::PCMAACDecodeThread(QObject *parent) : QThread(parent)
{
    connect(this,&QThread::finished,this,&QThread::deleteLater);
}

PCMAACDecodeThread::~PCMAACDecodeThread()
{

    disconnect();

    // 使run方法执行完成
    requestInterruption();

    quit();

    wait();

    qDebug() << "PCMAACDecodeThread destroy";
}

void PCMAACDecodeThread::run()
{

    PCMSpec pcmSpec;

//    pcmSpec.sampleRate = 48000;
//    pcmSpec.sampleFormat = AV_SAMPLE_FMT_S16;
//    pcmSpec.channelLayout = AV_CH_LAYOUT_STEREO;
    pcmSpec.inPath = "/Users/apple/Documents/ffmpeg/qt/audio/recode_pcm_48000_2_16.aac";
    pcmSpec.outPath = "/Users/apple/Documents/ffmpeg/qt/audio/recode_pcm_48000_2_16_aac_decode_02.pcm";

    FFMPEGUtils::pcmAACDecode(pcmSpec);


    qDebug() << "sampel rate: " << pcmSpec.sampleRate;
    qDebug() << "sampleFormat: " << av_get_sample_fmt_name(pcmSpec.sampleFormat);
    qDebug() << "channel number: " << av_get_channel_layout_nb_channels(pcmSpec.channelLayout);


}



